Skip to content

Conversation

@fennecJ
Copy link
Collaborator

@fennecJ fennecJ commented Sep 22, 2024

Previously, the compiler would throw a segmentation fault if the compiled code contained a declaration after a return statement. For example:

int main() {
return 0;
int a = 5;
}

This occurred when the basic block (bb) for unreachable code was null, while the function add_symbol(basic_block_t *bb, var_t *var) did not check for null before attempting to insert a variable, leading to a segmentation fault.

This commit fixes the issue by skipping symbol insertion if the basic block is unreachable (null).

@fennecJ fennecJ force-pushed the skip_symbol_insertion_in_unreachable_BB branch from ab6460f to 7cd3787 Compare September 22, 2024 02:48
Previously, the compiler would throw a segmentation fault if the
compiled code contained a declaration after a return statement.
For example:

int main() {
    return 0;
    int a = 5;
}

This occurred when the basic block (bb) for unreachable code was null,
while the function add_symbol(basic_block_t *bb, var_t *var) did not
check for null before attempting to insert a variable, leading to a
segmentation fault.

This commit fixes the issue by skipping symbol insertion if the basic
block is unreachable (null).
@fennecJ fennecJ force-pushed the skip_symbol_insertion_in_unreachable_BB branch from 7cd3787 to 1a11b2a Compare September 22, 2024 02:48
@jserv jserv requested a review from vacantron September 22, 2024 04:06
@jserv jserv merged commit 6261f31 into sysprog21:master Sep 25, 2024
4 checks passed
@jserv
Copy link
Collaborator

jserv commented Sep 25, 2024

Thank @fennecJ for contributing!

@fennecJ fennecJ deleted the skip_symbol_insertion_in_unreachable_BB branch September 26, 2024 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants